<?
if (!defined('SMF'))
	die('Hacking attempt...');

global $smcFunc, $txt, $settings, $scripturl;
global $dbtables;

$title = $txt['bnt_news_title'];

//Check to see if the date was passed in the query string
if (!isset($_GET['startdate']))
{
	//The date wasn't supplied so use today's date
	$startdate = date("Y/m/d");
}
else
{
	$startdate = $_GET['startdate'];
}

$previousday = getpreviousday($startdate);
$nextday = getnextday($startdate);

echo '
 <table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td height="73" width="27%"><img src="', $settings['images_url'], '/bnt/bnnhead.gif" width="312" height="123" alt="The BlackNova Network"></td>
      <td height="73" width="73%" bgcolor="#000000" valign="bottom" align="right">
        <p><font size="-1">', $txt['bnt_news_info'], '</font></p>
        <p>', $txt['bnt_news_for'] ,' ', $startdate, '</p>
      </td>
    </tr>
    <tr>
      <td height="22" width="27%" bgcolor="#00001A">&nbsp;</td>
      <td height="22" width="73%" bgcolor="#00001A" align="right"><a href="', $scripturl, '?action=blacknova;sa=news;startdate=', $previousday, '">', $txt['bnt_news_prev'], '</a> - <a href="', $scripturl, '?action=blacknova;sa=news;startdate=', $nextday, '">', $txt['bnt_news_next'], '</a></td>
    </tr>';

//Select news for date range
$result = $smcFunc['db_query']('', '
	SELECT * FROM {raw:db_news}
	WHERE date > {string:starttime}
	AND date < {string:endtime}
	ORDER BY news_id DESC',
	array(
		'db_news' => $dbtables['news'],
		'starttime' => $startdate . ' 00:00:00',
		'endtime' => $startdate . ' 23:59:59'
	)
);

//Check to see if there was any news to be shown
if ($smcFunc['db_num_rows']($result) == 0)
{
    //No news
    echo '<tr><td bgcolor="#00001A" align="center">', $txt['bnt_news_flash'], '</td><td bgcolor="#00001A" align="right">', $txt['bnt_news_none'], '</td></tr></table><p align=left>';

    //Display link to the main page
    TextMainMenu();
    return;
}
else
{
	while ($row = $smcFunc['db_fetch_assoc']($result))
	{
		echo'
	<tr>
	      <td bgcolor="#000033" align="center">', $row['headline'], '</td>
	      <td bgcolor="#000033">
	        <p align="justify">', $row['newstext'], '</p><br>
	      </td>
	</tr>';
	}
}
$smcFunc['db_free_result']($result);

echo '
</table>
<p align=left>';

TextMainMenu();
?>
